
package ui.adapter;

import android.content.Context;
import android.widget.ImageView;

import net.ck.hzq.R;

import java.util.ArrayList;
import java.util.List;

import activity.glide.GlideApp;
import base.BaseViewHolder;
import base.SuperBaseAdapter;
import ui.model.MessageBean;
import util.StringUtils;


/**
 * 客服适配器
 * Created by chenjian on 19/2/27.
 */
public class CustomerAdapter extends SuperBaseAdapter<MessageBean> {

    List<MessageBean> mData = new ArrayList<>();
    Context mContext;
    String mPath;

    public CustomerAdapter(Context context, List<MessageBean> data, String path) {
        super(context, data);
        mContext = context;
        mData = data;
        mPath = path;
    }

    @Override
    protected void convert(BaseViewHolder holder, final MessageBean item, final int position) {
        ImageView bg = holder.getView(R.id.customer_right_image);
        if(!StringUtils.isEmpty(mPath)){
            GlideApp.with(mContext)
                    .load(mPath)
                    .error(R.drawable.about)
                    .placeholder(R.drawable.about)
                    .into(bg);
        }

        if (item.getMessageType() == 0) {
            holder.setVisible(R.id.customer_left_layout, true);
            holder.setVisible(R.id.customer_right_layout, false);
            holder.setText(R.id.customer_left_word, item.getContentInfo());
        } else {
            holder.setVisible(R.id.customer_left_layout, false);
            holder.setVisible(R.id.customer_right_layout, true);
            holder.setText(R.id.customer_right_word, item.getContentInfo());
        }

    }


    @Override
    protected int getItemViewLayoutId(int position, MessageBean item) {
        return R.layout.item_customer;
    }

}
